package com.hzgj.bcl.stats;


public class MethodCounter {
    private LongAdder successCount;
    private LongAdder totalCount;

    public MethodCounter() {
        this.successCount = new LongAdder();
        this.totalCount = new LongAdder();
    }


    public MethodCounter incSuccess() {
        successCount.add(1);
        return this;
    }

    public MethodCounter incTotal() {
        totalCount.add(1);
        return this;
    }

    public void clean() {
        successCount = new LongAdder();
        totalCount = new LongAdder();
    }

    public boolean hasCount() {
        return totalCount.intValue() > 0;
    }


    public long getSuccessCount() {
        return successCount.sum();
    }

    public long getTotalCount() {
        return totalCount.sum();
    }
}
